home *** CD-ROM | disk | FTP | other *** search
- Path: sasabe.acms.arizona.edu!jwhite
- From: Kenton White <jwhite@sasabe.acms.arizona.edu>
- Newsgroups: comp.lang.c++
- Subject: Passing a pointer to a class function
- Date: Wed, 17 Jan 1996 16:54:03 -0700
- Organization: The University of Arizona
- Message-ID: <Pine.SUN.3.91.960117160141.13519A-100000@sasabe.acms.arizona.edu>
- NNTP-Posting-Host: sasabe.acms.arizona.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
-
- I have a library subroutine that takes as an argument a pointer to a
- function. I want to pass instead a pointer to a class function. The
- class looks like this:
-
- class device {
-
- // ...
-
- public:
-
- //...
- void derivs(float, complex*, complex*)
- };
-
- The subroutine expects a pointer to a function like this:
-
- rk(void (*)(float, void*, void*))
-
- I pass the class function like this:
-
- device laser;
- rk(void (*)(float,void*, void*))laser.derivs;
-
- When it compiles it gives me an anachronism warning and then crashes
- with a memory fault on execution. I have developed a temporary fix by
- declaring a seperate function in the main program called derivs that
- calls the class function derivs. This works but is silly. Is there a
- way to pass the pointer to the class function?
-
- Kenton
-
-